 <!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加商品类型</title>
	<hdjs/>
</head>
<body> 
	<form method="post" class="hd-form" enctype="multipart/form-data">
	<input type="hidden" name="gid" value="{$field.gid}">
	<div class="wrap">
				<div class="menu_list">
					<ul>
						<li>
							<a href="{|U:'index'}">
								商品列表
							</a>
						</li>
						<li>
							<a href="javascript:;" class="action">
								修改商品
							</a>
						</li>
					</ul>
				</div>

				<div class="tab">
					<ul class="tab_menu">
						<li lab="base"><a href="javascript:;">基本信息</a></li>
						<li lab="content"><a href="javascript:;">详细信息</a></li>
						<li lab="pic"><a href="javascript:;">图片</a></li>
					</ul>
					<div class="tab_content">
						<div id="base">
							<table class="table1">
								<tr>
									<th>名称</th>
									<td><input type="text" name="gname" class="w300" value="{$field.gname}"></td>
								</tr>
								
								<tr>
									<th>属性</th>
									<td>
										<label><input type="checkbox"   name="flag[]" value="推荐">推荐</label>
										<label><input type="checkbox"   name="flag[]" value="置顶">置顶</label>
										<script type="text/javascript">
										var f="{$field.flag}",flag=f.split(",");
										$(":checkbox").each(function(){
											var v=$(this).val();
											for(var i in flag){
												if(flag[i]==v){
													$(this).attr('checked','checked');
												}
											}
										})
										</script>
									</td>
								</tr>
								<tr>
									<th>栏目</th>
									<td>
										<select name="cid">
											<list from="$category" name='cat'>
											<option value="{$cat.cid}" <if value="{$field.cid}=={$cat.cid}"> selected="" </if> >{$cat._name}</option>
											</list>	
										</select>
									</td>
								</tr>
					<!-- 库存表数据更改 --> 
								<tr>
									<th>属性</th>
									<td>
										<table>
											<list from="$stock" name="goodsattr">
											<tr>
												<th>{$goodsattr.attr_name}</th>
												<td>{$goodsattr.html}</td>
											</tr>
											</list>
										</table>
									</td>
								</tr>
								<tr>
									<th>规格</th>
									<td>
										<table>
											<thead>

											<tr>
											<list from="$specStock.attrClassData" name="spec">
												<td>{$spec.attr_name}</td>
											</list>	
												<td>库存</td>
												<td>价格</td>
												<td>货号</td> 
												<td><a href="javascript:;" onclick="addStock(this)">添加（+）</a></td>
											</tr>
											</thead>
											<tbody id="tbody">
										<list from="$specStock.htmlData" name="html">
												{$html}
										</list>	

											</tbody>
											<script type="text/javascript">
													function addStock(obj){
														var html=$('.btn').eq(0).clone().find("[type='hidden']").remove().end();
														$('#tbody').append(html);
													}
													function removeStock(obj){
														var index=$('.btn').index();
														if(index>0){
															$(obj).parents(".btn").remove();
														}
													}

											</script>
										</table>
									</td>
								</tr>
	

								 <if value="!$specStock">
								<tr>
									<th>价格</th>
									<td><input type="text" name="price" value="{$field.price}" class="w300">
										
									</td>
								</tr>
								<tr>
									<th>库存</th>
									<td><input type="text" name="stock" value="{$field.stock}" class="w300"></td>
								</tr>
							</if>
								<tr>
									<th>关键词</th>
									<td><input type="text" name="keywords" value="{$field.keywords}" class="w300"></td>
								</tr>
								<tr>
									<th>描述</th>
									<td>
										<textarea name="description" class="w400 h100">{$field.description}</textarea>
									</td>
								</tr>
							</table>
						</div>
						<div id="content">
							<table class="table1">
								<tr>
									<th class="w100">内容</th>
									<td><ueditor name='body' content="{$field.body}"></td>
								</tr>
								<tr>
									<th class="w100">服务</th>
									<td><input type="text" name='service' value="{$field.service}"></td>
								</tr>
								<tr>
									<th class="w100">查看次数</th>
									<td><input type="text" name="click" value="{$field.click}"></td>
								</tr>
								<tr>
									<th class="w100">发表时间</th>
									<td class="h150"><input type="text" id="addtime" name="addtime" value="{$field.addtime}"></td>
								</tr>
								<script type="text/javascript">
									$('#addtime').calendar({format: 'yyyy/MM/dd HH:mm:ss'});
								</script>
							</table>
						</div>
						<div id="pic">
							<table class="table1">
								<tr>
									<th class="w100">首页图</th>
									<td >
										<input type="file" name="index_pic">
										<img src="__ROOT__/{$field.index_pic}"  class="w150 h150">
										<input type="hidden" name="index_pic" value="{$field.index_pic}">
									</td>
								</tr>
								<tr>
									<th class="w100">列表图</th>
									<td >
										<input type="file" name="list_pic">
										<img src="__ROOT__/{$field.list_pic}"  class="w100 h100">
										<input type="hidden" name="list_pic" value="{$field.list_pic}">
									</td>
								</tr>
								<tr>
									<th class="w100">添加内容页图</th>
									<td >
										<ul id="button">
											<li><input  type="file" name="pic[]"><button type="button" id="but1"  class="hd-cancel">添加</button></li>
										</ul>

									</td> 
								</tr>
								<tr>
									<th class="w100">已有图</th>
									<td >
										<ul id="pic">
											
											<list from="$pic" name="pic">
											<li>
												<img src="__ROOT__/{$pic.medium}" class="w200" ><span pid="{$pic.pid}">x</span>
											</li>

											</list>
										</ul>
									</td>
								</tr>
								
							</table> 
						</div>
					</div>
				</div>
				<div class='position-bottom'>
					<input type="submit" value="确定" class='hd-success'>
				</div>
	</div>
	</form>
</body>
<script type="text/javascript">
	$(function(){
		$('#pic li span').click(function(){
			var pid=$(this).attr('pid');
			$.post("{|U:'pic'}",{"pid":pid});
			$(this).parent('li').remove();
		})
	})
	$(function(){
		var data='<li><input type="file" name="pic[]"><button id="but" type="button"  class="hd-cancel">删除</button></li>';
		$("#but1").click(function(){
			$(this).parent().append(data);
		})
		$("#but").live('click',function(){
			$(this).parent('li').remove();
		})

	})
// </script>
<style type="text/css">
	ul#pic li{
		position: relative;
		width: 200px;
		margin:5px 20px;
		border:1px solid #ccc;
	}
	ul#pic li span{
		position: absolute;
		display: block;
		right: 5px;
		top: 0px;
		font-size: 20px;
		cursor: pointer;
		color: red;
	}
</style>
</html>